<template>
  <div class="publicBox" id="shoperCss">
    <div class="boxItem" id="publicSearch">      

<el-form ref="form" :inline="true"  class="demo-form-inline">
    <el-row>
  <el-form-item label="订单编号">
            <el-input class="pubIptS" v-model="orderNo"  placeholder="输入订单编号"></el-input>
  </el-form-item>
    <el-form-item label="故障单编号">
            <el-input class="pubIptS" v-model="faultno"  placeholder="故障单编号"></el-input>
  </el-form-item>
    <el-form-item label="交易时间" class="pubSltL">
        <el-date-picker
        v-model="createTime"
        type="date"
        placeholder="请选择时间">
        </el-date-picker>
  </el-form-item>
  <el-form-item label="订单状态" :required="false" class="label_right" >
  <el-select v-model="status" filterable  placeholder="全部" class="pubSlt138">
    <el-option
      v-for="item in orderStatus"
      :key="item.id"
      :label="item.name"
      :value="item.id" 
      >
    </el-option>
  </el-select>
  </el-form-item>
 <el-form-item class="label_btn">
            <el-button class="pubBtnBlue" @click="init" type="primary">查询</el-button>
            <el-button class="pubBtnBlue" @click="exportFn"  type="primary">导出</el-button>
  </el-form-item>
    </el-row>
   
   <el-row>
        <el-form-item>
            <el-button class="pubBtnGree"  type="primary" @click="Newcoupon()">新建</el-button>
  </el-form-item>
   </el-row>
</el-form>
</div>
          
          <public-table  
           @handleEdit="handleEdit" 
          :columnDefs="columnDefs" 
          @changePage="changePage"
          :tableData="tableData" 
          :order=true
          :total="total"
          :btn="['edit']"
          ></public-table>
  </div>
</template>

<script>
import publicTable from "@/components/public/publicTable.vue"
import *as API from "@api/operate.js"
import * as pubAPI from '@api/public.js'
import  baseConfig from '@api/common/baseconfig.js'
export default {
  components: {
         publicTable
  },
  data() {
    return {
        pageNum:1,
        pageSize:100,
        total:0,
        orderNo:'',
        faultno:'',
        createTime:'',
        status:'',
        columnDefs :[
            {headerName: '创建时间', field: 'createtime',width:180},
            {headerName: '故障单编号', field: 'no',width:150},
            {headerName: '订单编号', field: 'orderno',width:173},
            {headerName: '设备编号', field: 'equipmentno',width:200},
            {headerName: '故障描述', field: 'reason',width:300},
            {headerName: '状态', field: 'statusname',width:95},
        ],
        tableData: [],
        value:'',
        orderStatus: [{
          id: '0',
          name: '全部'
        },{
          id: '1',
          name: '审核中'
        }, {
          id: '2',
          name: '驳回'
        }, {
          id: '3',
          name: '转维修'
        }],
    }
  },
  // 计算属性，会监听依赖属性值随之变化
  computed: {


  },
  // 监控data中的数据变化
  watch: {


 },
  methods: {
   changePage(pageSize,pageNum){
          this.pageSize=pageSize;this.pageNum=pageNum
          this.init()
    },
    Newcoupon(){
       this.$router.push({path:"/platform/operate/faultNewbuild"})
    },
    async init(){
      let params={orderNo:this.orderNo,no:this.faultno,createTime:this.createTime,status:this.status,page:this.pageNum,size:this.pageSize}
      await API.getfaultAPI(params).then(res=>{
        if(res.IsPositive){
          console.log(res)
          this.tableData = res.Data
        }
      })
    },
    async exportFn(){
        await API.exportFault(this.ruleForm,baseConfig.baseUrl).then(res=>{
              pubAPI.creatExcelFn("设备故障管理.xlsx",res)
        })
    },
    handleEdit(row){   //编辑
    console.log(row.status)
    if(row.status == 1){
      this.$router.push({path:"/platform/operate/faultNewbuild",query:{data:row}})
    }else{
      return
    }
      
    },
  },
  created() {
          this.init()
  },
  mounted() {


  },
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {}, // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>

<style lang='less' scoped>
@import "../../styles/less/public.less";
  #shoperCss{
    .boxItem{
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      align-items: center;
      .demo-form-inline{
        align-items: center;
      }
      .itemp{
      font-size: 16px;
      } 
      .label_right{
            margin-left: 10px;
        }
        .label_btn{
            margin-left: 42px;
        }
    }
    .two_form{
        display: block;
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        .two_form_item{
            width: 1190px;
        }
        .two_form_item_a{
            width: 90px;
        }
    }
  }

</style>